home *** CD-ROM | disk | FTP | other *** search
Wrap
<?xml version="1.0" encoding="utf-8"?> <html><head><title>Split Function [Runtime]</title><meta name="filename" content="text/sbasic/common/03120314"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css"> p.P1{ } span.T1{ font-weight:bold;} </style></head><body> <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="split" xmlns:help="http://openoffice.org/2000/help"> <p class="Head1"><help:paragraphinfo state="U" number="1"/><help:key-word value="Split; function" tag="kw68668_1"/><help:link Id="68668">Split Function [Runtime]</help:link></p> <p class="Paragraph"><help:paragraphinfo state="U" number="2"/>Returns an array of substrings from a string expression.</p> <help:paragraphinfo state="E"/></help:to-be-embedded> <p class="Head2"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>Syntax:</p> <p class="Paragraph"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/>Split (Text As String, delimiter, number)</p> <p class="Head2"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>Return value:</p> <p class="Paragraph"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>String</p> <p class="Head2"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/>Parameters:</p> <p class="Paragraph"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Text:</span> Any string expression.</p> <p class="Paragraph"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">delimiter (optional):</span> A string character that is used to delimit the Text. The default is the space character.</p> <p class="Paragraph"><help:paragraphinfo state="U" number="12" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">number (optional):</span> The number of substrings that you want to return.</p> <p class="Head2"><help:paragraphinfo state="U" number="10" xmlns:help="http://openoffice.org/2000/help"/>Example:</p> <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="splitjoinex" xmlns:help="http://openoffice.org/2000/help"> <p class="PropText"><help:paragraphinfo state="U" number="11"/>Dim a(3)</p> <p class="PropText"><help:paragraphinfo state="U" number="13"/>Sub main()</p> <p class="PropText"><help:paragraphinfo state="U" number="14"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>a(0) = "ABCDE"</p> <p class="PropText"><help:paragraphinfo state="U" number="15"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>a(1) = 42</p> <p class="PropText"><help:paragraphinfo state="U" number="16"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>a(2) = "MN"</p> <p class="PropText"><help:paragraphinfo state="U" number="17"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>a(3) = "X <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>Y Z"</p> <p class="PropText"><help:paragraphinfo state="U" number="18"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>JStr = Join1()</p> <p class="PropText"><help:paragraphinfo state="U" number="19"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Call Show(JStr, Split1(JStr))</p> <p class="PropText"><help:paragraphinfo state="U" number="20"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>JStr = Join2()</p> <p class="PropText"><help:paragraphinfo state="U" number="21"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Call Show(JStr, Split1(JStr))</p> <p class="PropText"><help:paragraphinfo state="U" number="22"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>JStr = Join3()</p> <p class="PropText"><help:paragraphinfo state="U" number="23"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Call Show(JStr, Split1(JStr))</p> <p class="PropText"><help:paragraphinfo state="U" number="24"/>End Sub</p> <p class="PropText"><help:paragraphinfo state="U" number="25"/>Function Join1()</p> <p class="PropText"><help:paragraphinfo state="U" number="26"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Join1 = Join(a(), "abc")</p> <p class="PropText"><help:paragraphinfo state="U" number="45"/>End Function</p> <p class="PropText"><help:paragraphinfo state="U" number="27"/>Function Join2()</p> <p class="PropText"><help:paragraphinfo state="U" number="28"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Join2 = Join(a(), ",")</p> <p class="PropText"><help:paragraphinfo state="U" number="29"/>End Function</p> <p class="PropText"><help:paragraphinfo state="U" number="30"/>Function Join3()</p> <p class="PropText"><help:paragraphinfo state="U" number="31"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Join3 = Join(a())</p> <p class="PropText"><help:paragraphinfo state="U" number="32"/>End Function</p> <p class="PropText"><help:paragraphinfo state="U" number="33"/>Function Split1(aStr)</p> <p class="PropText"><help:paragraphinfo state="U" number="34"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Split1 = Split(aStr, "D")</p> <p class="PropText"><help:paragraphinfo state="U" number="35"/>End Function</p> <p class="PropText"><help:paragraphinfo state="U" number="36"/>Sub Show(JoinStr, TheArray)</p> <p class="PropText"><help:paragraphinfo state="U" number="37"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>l = LBound(TheArray)</p> <p class="PropText"><help:paragraphinfo state="U" number="38"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>u = UBound(TheArray)</p> <p class="PropText"><help:paragraphinfo state="U" number="39"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>total$ = "=============================" + Chr$(13) + JoinStr + Chr$(13) + Chr$(13)</p> <p class="PropText"><help:paragraphinfo state="U" number="40"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>For i = l To u</p> <p class="PropText"><help:paragraphinfo state="U" number="41"/> <text:s text:c="7" xmlns:text="http://openoffice.org/2000/text"/>total$ = total$ + TheArray(i) + Str(Len(TheArray(i))) + Chr$(13)</p> <p class="PropText"><help:paragraphinfo state="U" number="42"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>Next i</p> <p class="PropText"><help:paragraphinfo state="U" number="43"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/>MsgBox total$</p> <help:paragraphinfo state="E"/> <text:s text:c="3" xmlns:text="http://openoffice.org/2000/text"/> <p class="PropText"><help:paragraphinfo state="U" number="44"/>End Sub</p> <help:paragraphinfo state="E"/></help:to-be-embedded> </body></html>